// pages/dingdanxiangqing/dingdanxiangqing.js
const app = getApp();
var ea = require('../../utils/each.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    getparutUrl: app.data.url +'/mapi/index/productinfo',
    imgUrls: [
      '../../assets/shoujixi.png',
      '../../assets/shoujixi.png',
      '../../assets/shoujixi.png',
    ],
    indicatorDots: true,
    autoplay: true,
    interval: 5000,
    duration: 1000,
    indicator: 'white',
    circular: true,

    chanpin:{
     name:'苹果手机',
     jieshao:'华为P30全面屏超感光来卡三摄变焦双景录像980芯片智能手机送26重礼官网旗舰店手机正品....',
      xianjia:'3500',
      yuanjia:'4000',
      canshu: '4000',
      guige: '4000',
    }
  },





  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var id = options.id;
    if(!id){
      wx.navigateBack({
        delta:1
      })
      return;
    }
    var that = this;
    var user = wx.getStorageSync('user');
    wx.request({
      url: that.data.getparutUrl,
      method:'post',
      data:{token:user.token,id:id},
      success:function(res){
        var data = res.data;
        if(data.code==200){
          console.log(data.data);
          that.setData({ chanpin:data.data});
        }else{
          wx.showToast({
            title: data.msg,
            icon:'none'
          })
        }
      }
    })

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    this.onLoad();
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    var user = wx.getStorageSync('user');
    var titles = wx.getStorageSync('titles');
    return {
      title: titles,
      path: '/pages/index/index?scene' + user.id,
    };
  }
})